/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.kleintjes.structural.adapter_pattern.Impl;

import com.kleintjes.structural.adapter_pattern.TemperatureInfo;
import com.kleintjes.structural.adapter_pattern.model.CelciusReporter;

/**
 *
 * @author Hughan.Kleintjes.hughanK@gmail.com
 */
public class TemperatureObjectReporter implements TemperatureInfo{

    CelciusReporter celciusReporter;
    
    public TemperatureObjectReporter() {
        celciusReporter = new CelciusReporter();
    }
    
    @Override
    public double getTemperatureInC() {
        return celciusReporter.getTeperatureInC();
    }

    @Override
    public double getTemperatureInF() {
        return cToF(celciusReporter.getTeperatureInC());
    }

    @Override
    public void setTemperatureInC(double temperatureInC) {
        celciusReporter.setTeperatureInC(temperatureInC);
    }

    @Override
    public void setTemperatureInF(double temperatureInF) {
        celciusReporter.setTeperatureInC(fToC(temperatureInF));
    }
    
    private double fToC(double f) {
        return ((f-32)*5/9);
    }
    private double cToF(double c) {
        return ((c*9/5) + 32);
    }
    
}
